package com.yml.mall.order;

import com.yml.mall.user.pojo.UserDO;
import com.yml.mall.vo.ResponseVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

import static com.yml.mall.consts.myConst.CURRENT_USER;

/**
 * @ClassName OrderController
 * @Author Administrator
 * @Date 2020/4/15   16:49
 */
@RestController
@Slf4j
@Validated
public class OrderController {
    @Autowired
    OrderService orderService;
    @PostMapping("/orders")
    public ResponseVO create(@RequestBody Integer shippingId, HttpSession session){
        UserDO userDO = (UserDO)session.getAttribute(CURRENT_USER);
        return orderService.create(shippingId,userDO.getId());
    }
}
